package com.rd.student.jiaji.class3.xumingze.day0801;

import java.util.Arrays;

public class Test01 {

    public static void main(String[] args) {
        test01();
        System.out.println("-------------");
        test02();
    }

    public static void test01(){
        int[] arr = new int[10];
        for(int i = 0;i < 10;i++){
            if(i == 9)
                break;
            else arr[i] = 2 * i + 1;
        }
        System.out.println(Arrays.toString(arr));

        int[] arr1 = new int[]{10};
        int[] arr2 = new int[10];

        System.arraycopy(arr,0,arr2,0,5);
        System.out.println(Arrays.toString(arr2));

        System.arraycopy(arr1,0,arr2,5,1);
        System.out.println(Arrays.toString(arr2));

        System.arraycopy(arr,5,arr2,6,4);
        System.out.println(Arrays.toString(arr2));
    }

    public static void test02(){
        int[] arr = new int[9];
        for(int i = 0;i < 9;i++){
            if(i == 5){
                continue;
            }
            else arr[i] = 2 * i + 1;
        }
        System.out.println(Arrays.toString(arr));

        for(int i  = 0; i < arr.length;i++){
            if(i == 8){
                int swap = 0;
                swap = arr[i];
                arr[i] = arr[5];
                arr[5] = swap;
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}

